package com.salary.common;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class SpringBeanUtil implements ApplicationContextAware {

	private static ApplicationContext ctx;

	@Override
	public void setApplicationContext(ApplicationContext arg0)
			throws BeansException {
		ctx = arg0;
	}
	public static Object getBean(String id) {
		if (ctx == null) {
			throw new NullPointerException();
		}
		return ctx.getBean(id);
	}

}
